import request from './request';
import mockRequest from './mockRequest'

//获取三级导航列表
export const reqCategoryList = () => {
    return request({
        url: '/product/getBaseCategoryList',
        method: 'get'
    })
}

//获取搜索商品列表
export const reqSearchList = (data) => {
    return request({
        url: '/list',
        method: 'post',
        data
    })
}

//获取detail接口(商品详情)
export const reqDetailList = (skuId) => {
    return request({
        url: `/item/${skuId}`,
        method: 'get'
    })
}

//添加购物车接口
export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
    return request({
        url: `cart/addToCart/${skuId}/${skuNum}`,
        method: 'post'
    })
}

//获取购物车列表
export const reqShopCartList = () => {
    return request({
        url: `cart/cartList`,
        method: 'get'
    })
}

//切换商品选中状态
export const changeShopCartChecked = (skuId, isChecked) => {
    return request({
        url: `cart/checkCart/${skuId}/${isChecked}`,
        method: 'get'
    })
}

//删除商品
export const deleteShopCart = (skuId) => {
    return request({
        url: `cart/deleteCart/${skuId}`,
        method: 'delete'
    })
}

//获取验证码
export const getCode = (phone) => {
    return request({
        url: `user/passport/sendCode/${phone}`,
        method: 'get'
    })
}

//用户注册
export const registerUser = (data) => {
    return request({
        url: `user/passport/register`,
        method: 'post',
        data
    })
}

//用户登录
export const loginUser = (data) => {
    return request({
        url: `user/passport/login`,
        method: 'post',
        data
    })
}

//获取用户信息
export const reqUserInfo = () => {
    return request({
        url: `/user/passport/auth/getUserInfo`,
        method: 'get',
    })
}

//用户退出
export const loginOut = () => {
    return request({
        url: `/user/passport/logout`,
        method: 'get',
    })
}

//获取banner图片接口(主页轮播图)
export const reqGetBannerList = () => {
    return mockRequest({
        url: '/banner',
        method: 'get'
    })
}

//获取floor接口
export const reqGetFloorList = () => {
    return mockRequest({
        url: '/floor',
        method: 'get'
    })
}

//获取用户地址信息
export const reqAddressInfo = () => {
    return request({
        url: `/user/userAddress/auth/findUserAddressList`,
        method: 'get',
    })
}

//获取用户购物清单
export const reqShopCartInfo = () => {
    return request({
        url: `order/auth/trade`,
        method: 'get',
    })
}

//提交订单
export const reqSubmitOrder = (tradeNo, data) => {
    return request({
        url: `order/auth/submitOrder?tradeNo=${tradeNo}`,
        method: 'post',
        data
    })
}

//获取支付信息
export const reqOrderPay = (orderId) => {
    return request({
        url: `payment/weixin/createNative/${orderId}`,
        method: 'get'
    })
}
//获取支付状态
export const reqOrderStatus = (orderId) => {
    return request({
        url: `payment/weixin/queryPayStatus/${orderId}`,
        method: 'get'
    })
}

//获取我的订单
export const reqMyList = (page, limit) => {
    return request({
        url: `order/auth/${page}/${limit}`,
        method: 'get'
    })
}